<?php

namespace addons\TinyShare\common\models;

use Yii;
use common\behaviors\MerchantBehavior;
use common\helpers\StringHelper;

/**
 * This is the model class for table "{{%addon_share_like}}".
 *
 * @property int $id 点赞ID
 * @property int $merchant_id 商户ID
 * @property int $member_id 用户ID
 * @property int $content_id 内容ID
 * @property int $created_at 创建时间
 * @property int $updated_at 修改时间
 */
class ShareLike extends \common\models\base\BaseModel
{
	use MerchantBehavior;
	
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%addon_share_like}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['merchant_id', 'member_id', 'content_id', 'created_at', 'updated_at'], 'integer'],
            [['member_id', 'content_id'], 'required'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '点赞ID',
            'merchant_id' => '商户ID',
            'member_id' => '用户ID',
            'content_id' => '内容ID',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
        ];
    }
	
	/**
     * @param bool $insert
     * @return bool
     */
	public function beforeSave($insert)
    {
        $this->start_time = StringHelper::dateToInt($this->start_time);
        $this->end_time = StringHelper::dateToInt($this->end_time);

        return parent::beforeSave($insert);
    }
}
